#!/usr/bin/python
# -*- coding: UTF-8 -*-
import json


class Result:
    code = 200
    message = "Success"
    data = {}

    def __init__(self, code, message, data):
        self.code = code
        self.message = message
        self.data = data

    @staticmethod
    def success(message, data):
        return Result(200, message, data)

    @staticmethod
    def success1():
        return Result.success("Success", {})

    @staticmethod
    def success2(message):
        return Result.success(message, {})

    @staticmethod
    def success3(data):
        return Result.success("Success", data)

    @staticmethod
    def error(message, data):
        return Result(404, message, data)

    @staticmethod
    def error1():
        return Result.error("Error", {})

    @staticmethod
    def error2(message):
        return Result.error(message, {})

    @staticmethod
    def error3(data):
        return Result.error("Error", data)

    def json(self):
        "将实体转化为Json"
        return json.dumps(self, default=lambda obj: obj.__dict__, sort_keys=True, indent=4)
